﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:params="http://schemas.codeplex.com/elysium/params"
                    xmlns:controls="clr-namespace:Framework.UI.Controls">
    <ResourceDictionary.MergedDictionaries>
        <controls:SharedResourceDictionary Source="/Framework.UI;component/Themes/WPF/Base/Converter.xaml" />
        <controls:SharedResourceDictionary Source="/Framework.UI;component/Themes/WPF/Base/Brush.xaml" />
        <controls:SharedResourceDictionary Source="/Framework.UI;component/Themes/ElysiumExtra/BorderFix.xaml"/>
    </ResourceDictionary.MergedDictionaries>

    <Style x:Key="{x:Type ContextMenu}" TargetType="{x:Type ContextMenu}" >
        <Setter Property="Background" Value="{StaticResource BackgroundBrush}" />
        <Setter Property="BorderBrush" Value="{StaticResource LowlightBrush}" />
        <Setter Property="BorderThickness" Value="{Binding RelativeSource={RelativeSource Self},Path=(params:General.DefaultThickness),Mode=OneWay}" />
        <Setter Property="params:MenuBase.SubmenuBackground" Value="{Binding RelativeSource={RelativeSource Self},Path=Background,Mode=OneWay}" />
        <Setter Property="params:MenuBase.SubmenuBorderBrush" Value="{Binding RelativeSource={RelativeSource Self},Path=BorderBrush,Mode=OneWay}" />
        <Setter Property="params:MenuBase.SubmenuBorderThickness" Value="{Binding RelativeSource={RelativeSource Self},Path=BorderThickness,Mode=OneWay}" />
        <Setter Property="Foreground" Value="{StaticResource ForegroundBrush}" />
        <Setter Property="FontSize" Value="{Binding RelativeSource={RelativeSource Self},Path=(params:General.ContentFontSize),Mode=OneWay}" />
        <Setter Property="FontStretch" Value="Medium" />
        <Setter Property="FontStyle" Value="Normal" />
        <Setter Property="FontWeight" Value="Normal" />
        <Setter Property="TextOptions.TextFormattingMode" Value="Display" />
        <Setter Property="TextOptions.TextRenderingMode" Value="ClearType" />
        <Setter Property="RenderOptions.ClearTypeHint" Value="Enabled" />
        <Setter Property="ContextMenu.HasDropShadow" Value="{DynamicResource {x:Static SystemParameters.DropShadowKey}}" />
        <Setter Property="params:General.ShadowBrush" Value="{StaticResource ForegroundBrush}" />
        <Setter Property="Focusable" Value="False" />
        <Setter Property="FocusVisualStyle" Value="{x:Null}" />
        <Setter Property="Grid.IsSharedSizeScope" Value="True" />
        <Setter Property="HorizontalContentAlignment" Value="Stretch" />
        <Setter Property="VerticalContentAlignment" Value="Stretch" />
        <Setter Property="Padding" Value="{Binding RelativeSource={RelativeSource Self},Path=(params:General.BoldPadding),Mode=OneWay}" />
        <Setter Property="SnapsToDevicePixels" Value="True" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ContextMenu}">
                    <Border x:Name="LayoutRoot">
                        <controls:BorderFix Background="{TemplateBinding Background}" 
                                BorderBrush="{TemplateBinding BorderBrush}"
                                BorderThickness="{TemplateBinding BorderThickness}"
                                TextBlock.Foreground="{TemplateBinding Foreground}" 
                                TextBlock.FontFamily="{TemplateBinding Control.FontFamily}" 
                                TextBlock.FontSize="{TemplateBinding FontSize}" 
                                TextBlock.FontStretch="{TemplateBinding FontStretch}" 
                                TextBlock.FontStyle="{TemplateBinding FontStyle}" 
                                TextBlock.FontWeight="{TemplateBinding FontWeight}" 
                                TextOptions.TextFormattingMode="{TemplateBinding TextOptions.TextFormattingMode}" 
                                TextOptions.TextRenderingMode="{TemplateBinding TextOptions.TextRenderingMode}" 
                                RenderOptions.ClearTypeHint="{TemplateBinding RenderOptions.ClearTypeHint}" 
                                SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}">
                            <ItemsPresenter KeyboardNavigation.DirectionalNavigation="Cycle"/>
                        </controls:BorderFix>
                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="ContextMenu.HasDropShadow" Value="True">
                            <Setter TargetName="LayoutRoot" Property="UIElement.Effect">
                                <Setter.Value>
                                    <DropShadowEffect DropShadowEffect.BlurRadius="4" DropShadowEffect.ShadowDepth="2" DropShadowEffect.Direction="315" DropShadowEffect.Opacity="0.3" DropShadowEffect.Color="{Binding RelativeSource={RelativeSource AncestorType={x:Type ContextMenu}},Path=(params:General.ShadowBrush).(SolidColorBrush.Color)}" />
                                </Setter.Value>
                            </Setter>
                            <Setter TargetName="LayoutRoot" Value="{StaticResource TransparentBrush}" Property="Border.Background" />
                            <Setter TargetName="LayoutRoot" Property="Border.Padding" Value="0,0,6,6" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
        <Style.Triggers>
            <DataTrigger DataTrigger.Binding="{Binding RelativeSource={RelativeSource Self},Path=FontSize,Mode=OneWay,Converter={StaticResource IsGreaterThanConverter},ConverterParameter=18}">
                <Setter Property="TextOptions.TextFormattingMode" Value="Ideal" />
            </DataTrigger>
        </Style.Triggers>
    </Style>

</ResourceDictionary>